<template>
    <div class="contract-detial-page" :class="[isApprove ? 'approve':'no-approve',pageParams.readOnly ? 'readOnly':'']">
        <revokeContactDetial
            :Obj="Obj"
            :spinShow="spinShow"
            :isSP="isSP"
            :isApprove="isApprove"
            :pageParams="pageParams"
            :contractNo="contractNo"
            :receiptId="receiptId"
            :showRevoke="showRevoke"
            :dataDict="dataDict"
            :userInfo="userInfo"
            :roleType="roleType"
            :businessSource="businessSource"
            @changeValue="changeValue"
            @showSpin="showSpin"
            @closeSpin="closeSpin"
            @back="back"
        />
        <Spin size="large" fix v-if="spinShow"></Spin>
    </div>
</template>
<script>
    import {mapGetters} from "vuex";

    import {channelType, businessSource} from "_p/basic/api/contract/channel-type/channel-type";
    import {getDictDataList} from "_p/basic/assets/contract/js/utils";
    import revokeContactDetial from "./revoke-contact-detial/index";

    export default {
        name: "revokeHandleApprove",
        components: {revokeContactDetial},
        data() {
            return {
                Obj: {},
                spinShow: false,
                isSP: false, // 是否是供应商
                isApprove: true, //是否是审批页面
                pageParams: {},
                contractNo: null, //合同号
                businessSource: "",
                showRevoke: false,
                receiptId: "",
                caseNo: "",
                //  contractStatus 银行编码 receiptSourceType 付款方式 r caseStatus 状态
                dicttArr: ["bankCode", "receiptSourceType", "receiptStatus"],
                dataDict: {}
            };
        },
        computed: {
            ...mapGetters({userInfo: "userInfo", roleType: "roles"})
        },
        created() {
            this.getParams();
        },
        mounted() {
            this.init();
            console.group("页面初始数据：");
            console.log("userInfo:", this.userInfo);
            console.log("pageParams:", this.pageParams);
            console.log("roleType:", this.roleType);
            console.log("isSP:", this.isSP);
            console.log("businessSource:", this.businessSource);
            console.log("isApprove:", this.isApprove);
            console.log("contractNo:", this.contractNo);
            console.groupEnd();
        },
        methods: {
            init() {
                this.getDictDataList();
            },
            // 获取初始数据
            getParams() {
                const pageParams = this.afs.getPageParams(this);
                const {contractNo, caseNo, processStatus} = pageParams;
                this.pageParams = pageParams;
                this.contractNo = contractNo;
                this.caseNo = caseNo;
                this.pageParams.readOnly = false,
                    this.businessSource = businessSource(this.roleType);
                this.Obj = {
                    caseNo: caseNo,
                    contractNo: contractNo,
                    isFinance: true,
                    roleType: this.roleType
                };
                this.isSP = channelType(this.$route.meta.params);
            },
            getDictDataList() {
                getDictDataList(this.dicttArr).then(res => {
                    console.group("数据字典:");
                    console.log(this.dicttArr.join("  "));
                    console.log(JSON.parse(JSON.stringify(res)));
                    console.groupEnd();
                    this.dataDict = res;
                    this.dataDict.treatmentMethodDict = [{title: "收入", value: 'income'}, {
                        title: '退款',
                        value: 'refund'
                    }];
                });
            },
            showSpin() {
                this.spinShow = true;
            },
            closeSpin() {
                this.spinShow = false;
            },
            back() {
                //关闭页面
                this.afs.closeTab(this);
            },
            changeValue(receiptId) {
                this.receiptId = receiptId;
                this.showRevoke = true;
            }
        }
    };
</script>
<style lang="less">
    @import "../../../styles/common/form.less";
</style>
